﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
 

namespace WPF各种控件样式
{
    /// <summary>
    /// Interaction logic for Windows.xaml
    /// </summary>
    public partial class Windows : Window
    {
        public Windows()
        {
            InitializeComponent();
            Binding bindging = new Binding("Value") { Source = this.slidel };
            bindging.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            RangeValidationRule rvr = new RangeValidationRule();
            rvr.ValidatesOnTargetUpdated = true;
            bindging.ValidationRules.Add(rvr);
            bindging.NotifyOnValidationError = true;
            txt_no.SetBinding(TextBlock.TextProperty,bindging);
             txt_no.AddHandler(Validation.ErrorEvent, new RoutedEventHandler(DoValidation));


            //slider
            spanel.DataContext = GetCountryList();
            List<Country> dc = GetCountryList();
            object obj = from stu in dc where stu.Name.StartsWith("中") select stu;
          
        }
        void DoValidation(object sender, RoutedEventArgs e)
        {

        }
        private List<Country> GetCountryList()
        {
            List<Country> countryList = new List<Country>();
            List<Provice> proviceList = new List<Provice>();
            List<City> cityList1 = new List<City>();
            cityList1.Add(new City() { Name = "成都" });
            List<City> cityList2 = new List<City>();
            cityList2.Add(new City() { Name = "开县" });
            List<City> cityList3 = new List<City>();
            cityList3.Add(new City() { Name = "赤峰" });

            proviceList.Add(new Provice() { Name = "四川", CityList = cityList1 });
            proviceList.Add(new Provice() { Name = "重庆", CityList = cityList2 });
            proviceList.Add(new Provice() { Name = "内蒙古", CityList = cityList3 });
            countryList.Add(new Country() { Name = "中国", ProviceList = proviceList });
            return countryList;
        }
    }
    public class Country
    {
        public string Name { get; set; }
        public List<Provice> ProviceList { get; set; }
    }
    public class Provice
    {
        public string Name { get; set; }
        public List<City> CityList { get; set; }
    }
    public class City
    {
        public string Name { get; set; }
    }

}
